import json

from flask import make_response, jsonify, request, Response, current_app

from model.base_model import MyBaseModel
from utils.type_util import ContentTypeUtil

response = Response()


class RespUtil:

    @classmethod
    def respJson(cls, base: MyBaseModel):
        base.path = request.path
        # if request.method == "GET":
        #     base.request_params = request.args
        # if request.method != "GET"  request.data is not None:
        #     base.request_params = json.loads(request.data)
        # response.mimetype = ContentTypeUtil.json
        # response.content_type = ContentTypeUtil.json
        # response.data = jsonify(base.__dict__)
        # response.status = 200
        return jsonify(base.__dict__)

    @classmethod
    def respHtml(cls, htmlStr):
        response.content_type = ContentTypeUtil.html
        return response

    @classmethod
    def respStream(cls, htmlStr):
        response.content_type = ContentTypeUtil.stream
        return response
